<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('人员档案信息表')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <da-ryxx-modal ref="modalForm" @ok="modalFormOk"></da-ryxx-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import DaRyxxModal from './modules/DaRyxxModal'

  export default {
    name: 'DaRyxxList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      DaRyxxModal
    },
    data () {
      return {
        description: '人员档案信息表管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'姓名',
            align:"center",
            dataIndex: 'xm'
          },
          {
            title:'身份证号',
            align:"center",
            dataIndex: 'sfzh'
          },
          {
            title:'性别',
            align:"center",
            dataIndex: 'xb'
          },
          {
            title:'出生年月',
            align:"center",
            dataIndex: 'csny'
          },
          {
            title:'民族',
            align:"center",
            dataIndex: 'mz'
          },
          {
            title:'入伍时间',
            align:"center",
            dataIndex: 'rwsj',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'退伍时间',
            align:"center",
            dataIndex: 'twsj',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'政治面貌',
            align:"center",
            dataIndex: 'zzmm'
          },
          {
            title:'入党时间',
            align:"center",
            dataIndex: 'rdsj',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'联系电话',
            align:"center",
            dataIndex: 'lxdh'
          },
          {
            title:'学历情况',
            align:"center",
            dataIndex: 'xlqk'
          },
          {
            title:'拟安置地',
            align:"center",
            dataIndex: 'nazd'
          },
          {
            title:'健康状态',
            align:"center",
            dataIndex: 'jkzt'
          },
          {
            title:'残疾性质',
            align:"center",
            dataIndex: 'cjxz'
          },
          {
            title:'入伍地',
            align:"center",
            dataIndex: 'rwd'
          },
          {
            title:'部队代号',
            align:"center",
            dataIndex: 'bddh'
          },
          {
            title:'退伍证号',
            align:"center",
            dataIndex: 'twzh'
          },
          {
            title:'安置方式',
            align:"center",
            dataIndex: 'azfs'
          },
          {
            title:'军龄',
            align:"center",
            dataIndex: 'jl'
          },
          {
            title:'入伍高校名称',
            align:"center",
            dataIndex: 'rwgxmc'
          },
          {
            title:'是否复学',
            align:"center",
            dataIndex: 'sffx'
          },
          {
            title:'奖惩信息',
            align:"center",
            dataIndex: 'jlxx'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/dary/daRyxx/list",
          delete: "/dary/daRyxx/delete",
          deleteBatch: "/dary/daRyxx/deleteBatch",
          exportXlsUrl: "/dary/daRyxx/exportXls",
          importExcelUrl: "dary/daRyxx/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'xm',text:'姓名'})
        fieldList.push({type:'string',value:'sfzh',text:'身份证号'})
        fieldList.push({type:'string',value:'xb',text:'性别'})
        fieldList.push({type:'string',value:'csny',text:'出生年月'})
        fieldList.push({type:'string',value:'mz',text:'民族'})
        fieldList.push({type:'date',value:'rwsj',text:'入伍时间'})
        fieldList.push({type:'date',value:'twsj',text:'退伍时间'})
        fieldList.push({type:'string',value:'zzmm',text:'政治面貌'})
        fieldList.push({type:'date',value:'rdsj',text:'入党时间'})
        fieldList.push({type:'string',value:'lxdh',text:'联系电话'})
        fieldList.push({type:'string',value:'xlqk',text:'学历情况'})
        fieldList.push({type:'string',value:'nazd',text:'拟安置地'})
        fieldList.push({type:'string',value:'jkzt',text:'健康状态'})
        fieldList.push({type:'string',value:'cjxz',text:'残疾性质'})
        fieldList.push({type:'string',value:'rwd',text:'入伍地'})
        fieldList.push({type:'string',value:'bddh',text:'部队代号'})
        fieldList.push({type:'string',value:'twzh',text:'退伍证号'})
        fieldList.push({type:'string',value:'azfs',text:'安置方式'})
        fieldList.push({type:'string',value:'jl',text:'军龄'})
        fieldList.push({type:'string',value:'rwgxmc',text:'入伍高校名称'})
        fieldList.push({type:'string',value:'sffx',text:'是否复学'})
        fieldList.push({type:'string',value:'jlxx',text:'奖惩信息'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>